import 'package:flutter/widgets.dart';
import 'package:myturngame/Theme.dart';

///技能
///@author Administrator
///@date 2023年2月9日23:51:07

abstract class Skill {
  String name;

  Skill(this.name);

  ///技能描述
  List<TextSpan> description();
}

///连击
class Skill001 extends Skill {
  int damageSum = 110;
  int damageCount = 2;

  //每一段伤害
  List<int> damageRateList = [];

  Skill001(this.damageSum, this.damageCount) : super('横扫千军') {
    updateDamageRate();
  }

  void updateDamageRate() {
    damageRateList =
        List.generate(damageCount, (index) => damageSum ~/ damageCount);
  }

  @override
  List<TextSpan> description() {
    var damageText = "";
    for (var value in damageRateList) {
      damageText += "$value% ";
    }
    return [
      const TextSpan(text: "造成", style: textStyleSkill),
      TextSpan(text: " ${damageRateList.length} ", style: textStyleSkillLight),
      const TextSpan(text: "段伤害，", style: textStyleSkill),
      TextSpan(text: damageText, style: textStyleSkillLight),
      const TextSpan(text: "。段数增加时，伤害会减少。", style: textStyleSkill),
    ];
  }
}

///攻击强化
class Skill002 extends Skill {
  int damageRate = 110;

  int criticalRate = 0;

  Skill002() : super('猛击');

  @override
  List<TextSpan> description() {
    var textList = [
      const TextSpan(text: "造成", style: textStyleSkill),
      TextSpan(text: " $damageRate% ", style: textStyleSkillLight),
      const TextSpan(text: "伤害。", style: textStyleSkill)
    ];
    if(criticalRate > 0){
      textList.add(const TextSpan(text: "有", style: textStyleSkill));
      textList.add(TextSpan(text: " $criticalRate% ", style: textStyleSkillLight));
      textList.add(const TextSpan(text: "概率触发暴击。", style: textStyleSkill));
    }
    return textList;
  }
}
